]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
loginManager: Use signal argument to detect preparing for sleep
authorSebastian Keller <skeller@gnome.org>
Wed, 26 Mar 2025 10:28:30 +0000 (11:28 +0100)
committerMarge Bot <marge-bot@gnome.org>
Mon, 31 Mar 2025 11:40:18 +0000 (11:40 +0000)
The DBus PreparingForSleep property on org.freedesktop.login1.Manager
does not trigger PropertyChanged signals, leading to wrong values due to
gdbus caching. In most cases it would have always been false.

Additionally it was not included in the XML interface description file
included in gnome-shell. So it was actually undefined.

Since this property is used in _calculateUserStateFromLogind() to
determine that a user is not active when closing the lid on a laptop,
the user was considered still active.

Fix this by storing the "start" argument from the PrepareForSleep signal
instead of trying to read from the property.

Fixes: 6a43b6f55 ("timeLimitsManager: Store screen time state on suspend/resume")
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8185
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3679>

js/misc/loginManager.js

index 191b5334fb2afb45c4c9ea6e77b5809fec32a7a5..9dd9fa251e1371fabb1ec0aa5cfe472cb589677c 100644 (file)
@@ -93,6 +93,8 @@ class LoginManagerSystemd extends Signals.EventEmitter {
     constructor() {
         super();
 
+        this._preparingForSleep = false;
+
         this._proxy = new SystemdLoginManager(Gio.DBus.system,
             'org.freedesktop.login1',
             '/org/freedesktop/login1');
@@ -224,6 +226,7 @@ class LoginManagerSystemd extends Signals.EventEmitter {
     }
 
     _prepareForSleep(proxy, sender, [aboutToSuspend]) {
+        this._preparingForSleep = aboutToSuspend;
         this.emit('prepare-for-sleep', aboutToSuspend);
     }
 
@@ -235,7 +238,7 @@ class LoginManagerSystemd extends Signals.EventEmitter {
      * @type {boolean}
      */
     get preparingForSleep() {
-        return this._proxy.PreparingForSleep;
+        return this._preparingForSleep;
     }
 
     _sessionRemoved(proxy, sender, [sessionId]) {